/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bd_tenencias;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Earving
 */
@Entity
@Table(name = "auto")
@NamedQueries({
    @NamedQuery(name = "Auto.findAll", query = "SELECT a FROM Auto a"),
    @NamedQuery(name = "Auto.findByIdAuto", query = "SELECT a FROM Auto a WHERE a.idAuto = :idAuto"),
    @NamedQuery(name = "Auto.findByMarca", query = "SELECT a FROM Auto a WHERE a.marca = :marca"),
    @NamedQuery(name = "Auto.findByModelo", query = "SELECT a FROM Auto a WHERE a.modelo = :modelo"),
    @NamedQuery(name = "Auto.findByAnio", query = "SELECT a FROM Auto a WHERE a.anio = :anio"),
    @NamedQuery(name = "Auto.findByPlaca", query = "SELECT a FROM Auto a WHERE a.placa = :placa"),
    @NamedQuery(name = "Auto.findByNumCilindros", query = "SELECT a FROM Auto a WHERE a.numCilindros = :numCilindros"),
    @NamedQuery(name = "Auto.findByNumPuertas", query = "SELECT a FROM Auto a WHERE a.numPuertas = :numPuertas"),
    @NamedQuery(name = "Auto.findByColor", query = "SELECT a FROM Auto a WHERE a.color = :color"),
    @NamedQuery(name = "Auto.findByTipo", query = "SELECT a FROM Auto a WHERE a.tipo = :tipo"),
    @NamedQuery(name = "Auto.findByCombustible", query = "SELECT a FROM Auto a WHERE a.combustible = :combustible"),
    @NamedQuery(name = "Auto.findByProcedencia", query = "SELECT a FROM Auto a WHERE a.procedencia = :procedencia"),
    @NamedQuery(name = "Auto.findByPrecio", query = "SELECT a FROM Auto a WHERE a.precio = :precio"),
    @NamedQuery(name = "Auto.findByNumSerie", query = "SELECT a FROM Auto a WHERE a.numSerie = :numSerie"),
    @NamedQuery(name = "Auto.findByNumMotor", query = "SELECT a FROM Auto a WHERE a.numMotor = :numMotor")})
public class Auto implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idAuto")
    private Integer idAuto;
    @Basic(optional = false)
    @Column(name = "marca")
    private String marca;
    @Basic(optional = false)
    @Column(name = "modelo")
    private String modelo;
    @Basic(optional = false)
    @Column(name = "anio")
    private int anio;
    @Basic(optional = false)
    @Column(name = "placa")
    private String placa;
    @Basic(optional = false)
    @Column(name = "num_cilindros")
    private String numCilindros;
    @Basic(optional = false)
    @Column(name = "num_puertas")
    private String numPuertas;
    @Basic(optional = false)
    @Column(name = "color")
    private String color;
    @Basic(optional = false)
    @Column(name = "tipo")
    private String tipo;
    @Column(name = "combustible")
    private String combustible;
    @Basic(optional = false)
    @Column(name = "procedencia")
    private String procedencia;
    @Basic(optional = false)
    @Column(name = "precio")
    private double precio;
    @Basic(optional = false)
    @Column(name = "num_serie")
    private String numSerie;
    @Basic(optional = false)
    @Column(name = "num_motor")
    private String numMotor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "auto")
    private List<Tenencia> tenenciaList;
    @JoinColumn(name = "idPropietario", referencedColumnName = "idPropietario")
    @ManyToOne(optional = false)
    private Propietario propietario;

    public Auto() {
    }

    public Auto(Integer idAuto) {
        this.idAuto = idAuto;
    }

    public Auto(Integer idAuto, String marca, String modelo, int anio, String placa, String numCilindros, String numPuertas, String color, String tipo, String procedencia, double precio, String numSerie, String numMotor) {
        this.idAuto = idAuto;
        this.marca = marca;
        this.modelo = modelo;
        this.anio = anio;
        this.placa = placa;
        this.numCilindros = numCilindros;
        this.numPuertas = numPuertas;
        this.color = color;
        this.tipo = tipo;
        this.procedencia = procedencia;
        this.precio = precio;
        this.numSerie = numSerie;
        this.numMotor = numMotor;
    }

    public Integer getIdAuto() {
        return idAuto;
    }

    public void setIdAuto(Integer idAuto) {
        this.idAuto = idAuto;
    }

    public String getMarca() {
        return marca;
    }

    public void setMarca(String marca) {
        this.marca = marca;
    }

    public String getModelo() {
        return modelo;
    }

    public void setModelo(String modelo) {
        this.modelo = modelo;
    }

    public int getAnio() {
        return anio;
    }

    public void setAnio(int anio) {
        this.anio = anio;
    }

    public String getPlaca() {
        return placa;
    }

    public void setPlaca(String placa) {
        this.placa = placa;
    }

    public String getNumCilindros() {
        return numCilindros;
    }

    public void setNumCilindros(String numCilindros) {
        this.numCilindros = numCilindros;
    }

    public String getNumPuertas() {
        return numPuertas;
    }

    public void setNumPuertas(String numPuertas) {
        this.numPuertas = numPuertas;
    }

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getTipo() {
        return tipo;
    }

    public void setTipo(String tipo) {
        this.tipo = tipo;
    }

    public String getCombustible() {
        return combustible;
    }

    public void setCombustible(String combustible) {
        this.combustible = combustible;
    }

    public String getProcedencia() {
        return procedencia;
    }

    public void setProcedencia(String procedencia) {
        this.procedencia = procedencia;
    }

    public double getPrecio() {
        return precio;
    }

    public void setPrecio(double precio) {
        this.precio = precio;
    }

    public String getNumSerie() {
        return numSerie;
    }

    public void setNumSerie(String numSerie) {
        this.numSerie = numSerie;
    }

    public String getNumMotor() {
        return numMotor;
    }

    public void setNumMotor(String numMotor) {
        this.numMotor = numMotor;
    }

    public List<Tenencia> getTenenciaList() {
        return tenenciaList;
    }

    public void setTenenciaList(List<Tenencia> tenenciaList) {
        this.tenenciaList = tenenciaList;
    }

    public Propietario getPropietario() {
        return propietario;
    }

    public void setPropietario(Propietario propietario) {
        this.propietario = propietario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAuto != null ? idAuto.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Auto)) {
            return false;
        }
        Auto other = (Auto) object;
        if ((this.idAuto == null && other.idAuto != null) || (this.idAuto != null && !this.idAuto.equals(other.idAuto))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "bd_tenencias.Auto[idAuto=" + idAuto + "]";
    }

}
